#!/bin/sh
# Ekos template & modified by Wolf Kodi
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
echo "<html>"
echo "    <head>"
echo "        <meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=iso-8859-1\" />"
echo "        <link rel=\"icon\" href=\"images/favicon.ico\" type=\"image/x-icon\" />"
echo "        <link rel=\"shortcut icon\" href=\"images/favicon.ico\" type=\"image/x-icon\" />"
echo "        <script type=\"text/javascript\" src=\"common.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"lang_pack/english.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"lang_pack/language.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"user/js/mypage_common.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"user/js/mypage_$(nvram get language).js\"></script>"
echo "        <link type=\"text/css\" rel=\"stylesheet\" href=\"style/$(nvram get router_style)/style.css\" />"
echo "        <!--[if IE]><link type=\"text/css\" rel=\"stylesheet\" href=\"style/$(nvram get router_style)/style_ie.css\" /><![endif]-->"
echo "        <script type=\"text/javascript\" src=\"js/prototype.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"js/effects.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"js/window.js\"></script>"
echo "        <script type=\"text/javascript\" src=\"js/window_effects.js\"></script>"
echo "        <link type=\"text/css\" rel=\"stylesheet\" href=\"style/pwc/default.css\" />"
echo "        <link type=\"text/css\" rel=\"stylesheet\" href=\"style/pwc/ddwrt.css\" />"
echo "        <link type=\"text/css\" rel=\"stylesheet\" href=\"user/style/mypage.css\" />"
echo "        <title>$(nvram get router_name) (build $(/sbin/softwarerevision)M) - "Live Usage"</title>"
echo "</head>"
echo "<body class=\"gui\" id=\"top\">"
echo "<div id=\"wrapper\">"
echo "<div id=\"content\">"
echo "<div id=\"header\">"
echo "<div id=\"logo\"><h1>DD-WRT Control Panel</h1></div>"
echo "<div id=\"menu\">"
echo " <div id=\"menuMain\">"
echo "  <ul id=\"menuMainList\">"
echo "   <li><a href=\"index.asp\">Setup</a></li>"
echo "   <li><a href=\"Wireless_Basic.asp\">Wireless</a></li>"
echo "   <li><a href=\"Services.asp\">Services</a></li>"
echo "   <li><a href=\"Firewall.asp\">Security</a></li>"
echo "   <li><a href=\"Filters.asp\">Access Restrictions</a></li>"
echo "   <li><a href=\"ForwardSpec.asp\">NAT / QoS</a></li>"
echo "   <li><a href=\"Management.asp\">Administration</a></li>"
echo "   <li><a href=\"Status_Router.asp\">Status</a></li>"
echo "   <li class=\"current\"><span>Live Usage</span>"
echo "    <div id=\"menuSub\">"
echo "     <ul id=\"menuSubList\">"
echo "      <li><span><b>Live Download/Upload Rate and Total Usage for Each User</b></span></li>"
echo "     </ul>"
echo "    </div>"
echo "    </li>"
echo "  </ul>"
echo "</div>"
echo "</div>"
echo "</div>"
echo "<div id=\"main\">"
echo "<div id=\"contents\">"
echo "<fieldset id=\"l1\">"    
cat /tmp/usage.html
echo "</fieldset><br />"
echo "</div>"
echo "</div>"
echo "<div id=\"helpContainer\">"
echo "<div id=\"help\">"
echo "<div><h2><script type=\"text/javascript\">Capture(share.help)</script></h2></div>"
echo "<dl>"
echo "<dt class=\"term\">Live Usage:</dt>"
echo "<dd class=\"definition\">This page shows you the live traffic of<br />individual users in the last 10 seconds.<br />It also shows you the record of total<br />usage for each user.</dd>"
echo "<dt class=\"term\">Visit discussion thread:</dt>"
echo "<dd class=\"definition\">Click on the link above.</dd>"
echo "</dl><br />"
echo "<a href=\"http://www.dd-wrt.com/phpBB2/viewtopic.php?t=75275\" title=\"Link to DD-WRT Forum Topic\">Link to DD-WRT Forum Topic</a>"
echo "</div>"
echo "</div>"
echo "<div id=\"floatKiller\"></div>"
echo "<div id=\"statusInfo\">"
echo "<div class=\"info\">Date: <span id=\"locdate\">$(date +%d" "%h" "%Y)</span> - <script type=\"text/javascript\">Capture(share.firmware)</script>: <a href=\"javascript:openAboutWindow();\" title=\"About\">$(cat /tmp/loginprompt|grep DD-WRT|cut -d' ' -f1) $(cat /tmp/loginprompt|grep DD-WRT|cut -d' ' -f2) ($(cat /tmp/loginprompt|grep Release|cut -d' ' -f2)) $(cat /tmp/loginprompt|grep DD-WRT|cut -d' ' -f3)</a></div>"
echo "<div class=\"info\"><script type=\"text/javascript\">Capture(share.time)</script>: <span id=\"uptime\">$(uptime)</span></div>"
echo "<div class=\"info\">$(nvram get DD_BOARD|awk '{ maxLen=21; len=length($0); split($0, a, " "); if (len>=maxLen) print substr(a[2],0,length(a[2])); else print substr($0,0,maxLen); }')&nbsp;-&nbsp;$(nvram get router_name|awk '{ maxLen=16; len=length($0); if (len>=maxLen) print substr($0,0,maxLen); else print substr($0,0,len); }')&nbsp;-&nbsp;WAN <span id=\"ipinfo\">&nbsp;IP:&nbsp;$(nvram get wan_ipaddr)</span></div>"
echo "</div>"
echo "</div>"
echo "</div>"
echo "</body>"
echo "</html>"